package com.czk.rdd.operator.transform

import org.apache.spark.{SparkConf, SparkContext}

/**
 * @Author:ChenZhangKun
 * @Date: 2021/12/9 11:39
 */
object Spark08_RDD_Operator_Transform {
  def main(args: Array[String]): Unit = {
    val sparkConf = new SparkConf().setMaster("local[*]").setAppName("RDD")
    val sc = new SparkContext(sparkConf)

    val rdd = sc.makeRDD(List(List(1,2),3,List(3,4)))

    val mapRDD = rdd.flatMap(
      data => {
        data match {
            // 数据类型判断
          case list: List[_] => list
          case date => List(date)
        }
      }
    )
    mapRDD.collect().foreach(println)
  }
}
